import consts from '@/consts.js'

const formatQualificationType = (value) => {
  value = value || ''
  return consts.qualificationType[value] || '未知'
}

const formatInvoType = (value) => {
  value = value || ''
  return consts.invoType[value] || '未知'
}
const formatCateStatus = (value) => {
  value = value || ''
  return consts.cateStatus[value] || '未知'
}

const formatDate = (value) => {
  var date = new Date(value)
  var y = date.getFullYear()
  var m = date.getMonth() + 1
  m = m < 10 ? '0' + m : m
  var d = date.getDate()
  d = d < 10 ? '0' + d : d
  return y + '-' + m + '-' + d
}

const formatTime = (value) => {
  var date = new Date(value)
  var Y = date.getFullYear()
  var M = date.getMonth() + 1
  M = M < 10 ? '0' + M : M
  var d = date.getDate()
  d = d < 10 ? '0' + d : d
  var h = date.getHours()
  h = h < 10 ? '0' + h : h
  var m = date.getMinutes()
  m = m < 10 ? '0' + m : m
  var s = date.getSeconds()
  s = s < 10 ? '0' + s : s
  return Y + '-' + M + '-' + d + ' ' + h + ':' + m + ':' + s
}

export default {
  formatQualificationType,
  formatInvoType,
  formatDate,
  formatTime,
  formatCateStatus
}
